#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>
#include<vector>

using namespace std;

vector<string> summaryRanges(vector<int>& nums) {
    if (nums.empty())    return {};
    int begin = nums[0], end = nums[0];
    vector<string> res;
    for (int i = 1; i < nums.size(); i++)
    {
        if (nums[i] == nums[i - 1] + 1)   end++;
        else
        {
            if (begin == end)
                res.push_back(to_string(begin));
            else
                res.push_back(to_string(begin) + "->" + to_string(end));
            begin = end = nums[i];
        }
    }
    if (begin == end)
        res.push_back(to_string(begin));
    else
        res.push_back(to_string(begin) + "->" + to_string(end));
    return res;
}

int main()
{
    vector<int> v = { 0,1,2,4,5,7 };
    summaryRanges(v);
    return 0;
}